//
//  TLMeVipTableViewCell.m
//  WXReader
//
//  Created by huaya on 2025/3/18.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLMeVipTableViewCell.h"

@interface TLMeVipTableViewCell ()
@property (weak, nonatomic) IBOutlet UIButton *rechargeBtn;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *titleLab;
@property (weak, nonatomic) IBOutlet UILabel *descLab;

@end

@implementation TLMeVipTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.bgView.clipsToBounds = YES;
    self.bgView.layer.cornerRadius = 8;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)rechargeAction:(id)sender {
    if (self.rechargeBlock) {
        self.rechargeBlock();
    }
}
- (IBAction)myWalletAction:(id)sender {
    if (self.myWalletBlock) {
        self.myWalletBlock();
    }
}
- (void)reloadView{
    if (TL_UserInfoManager.isLogin && TL_UserInfoManager.userInfo.userVip.intValue != 0) {
        self.titleLab.text = @"SVIP";
        self.descLab.text = [NSString stringWithFormat:@"Expiration date:%@", [NSDate convert2LocalTimeWithString:TL_UserInfoManager.userInfo.validUntil andWithFormatter:@"yyyy-MM-dd"]];
    }else{
        self.titleLab.text = @"VIP Membership";
        self.descLab.text = @"Unlimited Access to All Stories";
    }
}
- (void)layoutSubviews{
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self.bgView addDefaultHorizontalGradientBackground];
        [self.bgView updateGradientCornerRadius];
    });
    
}
@end
